﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using UcAsp.Models;
namespace UcAsp.Controllers
{
    public class FashionController : Controller
    {
        //
        // GET: /Fashion/
        private UcAspNetEntities entities = new UcAspNetEntities();
        public ActionResult Index()
        {
            var query = (from c in entities.Articless
                         join m in entities.Categoriess
                         on c.CategorieID equals m.ID
                         where m.ParentID == 2 && c.IsRelease == true
                         orderby c.ID descending
                         select c);
            int pagesize = 10;
            int pageindex = 0;
            if (Request.QueryString["page"] != null)
            {
                pageindex = int.Parse(Request.QueryString["page"].ToString()) - 1;
            }
            ViewData["PageIndex"] = pageindex + 1;
            ViewData["PageCount"] = (query.Count() + 9) / 10;
            List<Articles> list = new List<Articles>();
            list = query.Skip(pageindex * pagesize).ToList<Articles>().Take(pagesize).ToList();

            return View(list);
        }

    }
}
